<template>
	<view class="page">
		<!-- 搜索栏 -->
		<view class="search-bar">
			<view class="search-box">
				<image lazy-load="true"  src="../../static/images/search-img.png" class="search-img"></image>
				<input type="text" class="search-inp" confirm-type="search" @confirm="getVal" v-model="inputVal" placeholder="新建话题" placeholder-style="color:#cccccc" />
				<image lazy-load="true" v-if="inputVal" @click="cleanInput()"  src="../../static/images/close-btn.png" class="close-btn"></image>
			</view>
		</view>
		<!-- 新建话题 -->
		<view class="create-topic" v-if="inputVal" @click="get_topic(inputVal)">
			新建 #{{inputVal}}# 话题
		</view>
		<view class="tags" v-if="note_tags.length>0">
			<view class="">已有话题(你可以直接选择已有话题或者新建话题)</view>
			<view class="tags_list" >
				<view @click="get_topic(item)" v-for="(item , key) in note_tags" :key="key" class="create-topic">#{{item}}#</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				inputVal:'',
				note_tags:[]
			}
		},
		onLoad() {
			this.inputVal=uni.getStorageSync("topic") ? uni.getStorageSync("topic") : '';
			var self = this;
			this.$request.request({
				url:'/note/topics',
				success:function(res){
					self.note_tags = res.result;
				}
			});
			
			// #ifdef H5	
				let share_time_line={
					title:self.$request.h5_share_name, // 分享标题
					link: self.$request.h5_share_url+'?page=index', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					imgUrl: self.$request.h5_img_url+'/static/images/logo.png', // 分享图标
				}
				let share_app_message={
					title: self.$request.h5_share_name, // 分享标题
					desc: '我发现了一个很不错的商城，买家具有超大实惠！', // 分享描述
					link: self.$request.h5_share_url+'?page=index', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
					imgUrl: self.$request.h5_img_url+'/static/images/logo.png', // 分享图标
				}
				uni.setStorageSync('share_time_line',share_time_line);
				uni.setStorageSync('share_app_message',share_app_message);
				self.$request.wx_config()			
			
			// #endif
		},
		methods: {
			cleanInput(){
				this.inputVal='';
			},
			getVal(e){
				
			},
			get_topic(topic_name){
				uni.setStorageSync("topic",topic_name);
				uni.navigateBack({
				    delta: 1
				});
			}
		}
	}
</script>

<style>
	@import url("add-topic.css");
</style>
